{{!--
Copyright (C) 2017 Draios inc.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
--}}

{{#if isSizeKnown}}
    <div class="sd-table__wrap" style={{tableWrapStyle}}>
        <style class="style">
            {{{tableStyle}}}
        </style>
        <div class="sd-table__head">
            <div class="sd-table__head-row">
                {{#each columns key="id" as |column|}}
                    {{component
                        column.headComponentName
                        column=column
                        row=row
                        columnWidthUnit=columnWidthUnit
                    }}
                {{/each}}
            </div>
        </div>
        <div class="sd-table__body">
            {{#virtual-each rowsConfiguration
                height=bodyHeight
                itemHeight=rowHeight
                rowPadding=5
                scrollTimeout=10
                data-ref="body"
                as |dataRow|
            }}
                {{#sd-table-row
                    row=dataRow.configuration
                    isSelected=dataRow.isSelected
                    actionsTarget=actionsTarget
                    width=width
                    scrollX=scrollX
                    select=(action "select" dataRow)
                    activate=(action "activate" dataRow)
                    as |tableRow|
                }}
                    {{#each tableRow.configuration.columns key="@index" as |cell|}}
                        {{component
                            cell.configuration.cellComponentName
                            column=cell.configuration
                            value=cell.output
                            row=tableRow.configuration
                            cell=cell
                            isRowSelected=dataRow.isSelected
                            columnWidthUnit=columnWidthUnit
                        }}
                    {{/each}}
                {{/sd-table-row}}
            {{/virtual-each}}
        </div>
    </div>
{{/if}}